package cate.game.play.skill.passive.awaken;

import cate.common.table.d.GDSkill;
import cate.game.play.base.TargetFilterParam;
import cate.game.play.base.TargetSelector;
import cate.game.play.config.PlayCfgArgs;
import cate.game.play.fighter.Fighter;
import cate.game.play.proce.action.ctx.ActionCtx;
import cate.game.play.proce.action.ctx.SkillActionCtx;
import cate.game.play.proce.action.ctx.TimeActionCtx;
import cate.game.play.proce.move.MoveCtx;
import cate.game.play.skill.effect.SkillEffect;
import cate.game.play.skill.passive.PassiveHandler;

/**
 * 效果1：觉醒状态下受到当前生命小于50%的目标攻击时伤害减少12%;  （buff：临时属性变更）
 *            场上每有1个目标死亡则提升自身3.5%攻击(不可驱散),最多10层,持续到战斗结束
 * 效果2：【觉醒·黯灭】额外提升12%对法师/坦克的伤害；觉醒状态下攻击的目标在2回合内死亡则提升我方全体25%觉醒值，冷却2回合
 * 效果3：目标死亡后提升的攻击提升到5%,层数上限提升到15层;觉醒状态下出手时,对随机1名友方单位附加【光焰】(不可驱散),
 *                携带该状态的目标下回合会复制发起者1个正面状态,并净化自身1个负面状态
 */
public class 诛杀暗影之魂PH extends PassiveHandler {

	private int 死亡buff;
	private int 死亡添加buff;
	private int 出手buff;

	private byte 出手buff范围;

	//死亡buff=？？&死亡添加buff=？？&出手buff=？？&出手buff范围=??
	@Override
	public void parse(String code) {
		PlayCfgArgs args = new PlayCfgArgs(code);
		死亡buff = args.getInt("死亡buff", 0);
		死亡添加buff = args.getInt("死亡添加buff", 0);
		出手buff = args.getInt("出手buff", 0);
		出手buff范围 = args.getByte("出手buff范围", (byte)0);
	}

	@Override
	public void onOtherDead(ActionCtx action, Fighter killer, Fighter deader) {
		if(skill.owner.isDead()||!skill.owner.status.isAwaken()){
			return;
		}
		skill.owner.buff.tryAddByTid(action, 死亡buff);
	}

	@Override
	public void beforeSkillSettleAsActor(SkillActionCtx action, SkillEffect effect, Fighter target) {
		if (!action.getSkill().cfg.isHurtSkill()) {
			return;
		}
		if (skill.owner.isDead() || !skill.owner.status.isAwaken()) {
			return;
		}
		target.buff.tryAddByTid(action, skill.owner, 死亡添加buff);
	}

	@Override
	public void onOwnerMoveDone(MoveCtx move, TimeActionCtx action) {
		if (skill.owner.isDead() || !skill.owner.status.isAwaken()) {
			return;
		}
		Fighter one = TargetSelector.findOne(skill.owner, action.getTeamVs(), new TargetFilterParam().scopeSet(出手buff范围));
		if (one != null) {
			one.buff.tryAddByTid(action, skill.owner, 出手buff);
		}
	}
}
